import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

import VueTypedJs from 'vue-typed-js'

Vue.use(VueTypedJs)

//导入全局样式
import './assets/css/global.css'

//导入字体图标
import './assets/fonts/iconfont.css'

//导入树形插件
import TreeTable from 'vue-table-with-tree-grid'

//导入富文本插件
import VueQuillEditor from 'vue-quill-editor'

//导入富文本插件的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)

//引入nprogress相关的js和css
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'
axios.defaults.baseURL ="http://127.0.0.1:8888/api/private/v1/"
axios.interceptors.request.use(config=>{
  NProgress.start();
  config.headers.Authorization=window.sessionStorage.getItem('token')
  return config
})


//响应拦截器
axios.interceptors.response.use(
  config=>{
    NProgress.done();
    return config
  }
)



Vue.prototype.$http = axios

//全局注册树形组件
Vue.component('tree-table',TreeTable)


//引入mock.js
import './mock/mockServer'



//全局注册过滤器，处理时间函数
Vue.filter('dateFormat',function(origiinVal){
  const dt=new Date(origiinVal)
  const y=dt.getFullYear()
  //不足两位用0填充
  const m=(dt.getMonth()+1+'').padStart(2,'0')
  const d=(dt.getDay()+'').padStart(2,'0')
  const hh=(dt.getHours()+'').padStart(2,'0')
  const mm=(dt.getMinutes()+'').padStart(2,'0')
  const ss=(dt.getSeconds()+'').padStart(2,'0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')